<template>
  <div class="publicBox" id="shoperNewbuildCss">

<el-form ref="form" :model="ruleForm"  class="demo-form-inline publicEditFrom" :rules="rules" label-width="160px" label-position="left">

<el-row>
     <div class="pubPageTagP">
               <p>门店管理/新建</p>
     </div>
</el-row>

<el-row>
         <el-form-item label="门店名称" prop="name">
                 <el-input class="pubSerIpt" v-model="ruleForm.name"  placeholder="请输入门店名称"></el-input>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="门店地址" prop="address">
                 <el-input class="pubSerIpt" v-model="ruleForm.address"  placeholder="请输入门店地址"></el-input>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="门店经纬度" prop="coordinate">
                 <el-input class="pubSerIpt" v-model="ruleForm.coordinate"  placeholder="请输入门店经纬度"></el-input>
                 <a href="#" style="color:#617ADA">经纬度查询</a>
       </el-form-item>
       
</el-row>

<el-row>
        <el-form-item label="所在区域" class="label_right" prop="areaid">
        <el-select v-model="ruleForm.areaid"    filterable  placeholder="全部" class="pubSlt200">
            <el-option
            v-for="item in getselect"
            :key="item.id"
            :label="item.name"
            :value="item.id" 
            >
            </el-option>
        </el-select>
        </el-form-item>
</el-row>

<el-row>
         <el-form-item label="负责人" prop="id">
                 <el-input class="pubSerIpt" v-model="ruleForm.id"  placeholder="请输入该门店负责人"></el-input>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="联系电话" prop="phone">
                 <el-input class="pubSerIpt" v-model="ruleForm.phone"  placeholder="请输入负责人联系电话"></el-input>
       </el-form-item>
</el-row>

<el-row class="pubSubmitBtn-row">
           <el-form-item>
                         <el-button class="pubBtnGree" type="primary" @click="submitForm">提交</el-button>
                         <el-button class="pubBtnGray" @click="canCleFn"  type="primary">取消</el-button>
       </el-form-item>
</el-row>

</el-form>
    
  </div>
</template>

<script>
import * as API from "@api/shop.js"
export default {
  components: {

  },
  data() {
    return {
        value:'',
         getselect: [],
         pageNum:1,
        pageSize:100,
        
     ruleForm:{
      name:"",
      address:"",
      areaid:"",
      coordinate:"",
      id:"",
      phone:"",
     },
      rules: {
          name: [
            { required: true, message: '请输入门店名称', trigger: 'blur' }
          ],
          address: [
            {required: true, message: '请输入们带你地址', trigger: 'blur' }
          ],
          areaid: [
            {required: true, message: '请选择地区', trigger: 'blur' }
          ],
          id: [
            {required: true, message: '请输入负责人名称', trigger: 'blur' }
          ],
          phone: [
            {required: true, message: '请输入手机号码', trigger: 'blur' }
          ],
          coordinate: [
            {required: true, message: '请输入名店经纬度', trigger: 'blur' }
          ],
        }
    }
  },
  // 计算属性，会监听依赖属性值随之变化
  computed: {


  },
  // 监控data中的数据变化
  watch: {


 },
  methods: {
       canCleFn(){
           this.$router.go(-1)
       },
       submitForm() {
           this.$refs["form"].validate((valid) => {
            if (valid) {
                    this.addshopApi()
            } else {
              console.log('error submit!!');
              return false;
            }
        });
       },
       async addshopApi(){
         let res = await API.addshopApi(this.ruleForm)
            if(res.IsPositive){
              this.$message.success({message:"操作成功"})
              this.$router.push({path:'/platform/shop/shoper'})
            }else{
              this.$message.error({message:res.ErrorCode})
            }
       }

  },
  async created() {
      this.getselect = await this.$getSelect()

  },
  mounted() {


  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {}, // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style lang='less'>


</style>